package com.yangrui.app.mapper;

import com.yangrui.app.entity.Chapter;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ChapterMapper {
    /**
     *  根据VideoID查询
     *  @param videoId videoId
     *  @return chapter集合t55t5tt
     *
     */
    @Select("select id, id as chapter_id ,title,order_in_video,create_time from lesson.chapter where video_id=#{param1}")
    @Results({
            @Result(id = true ,  property = "id", column = "id" , jdbcType = JdbcType.INTEGER),
            @Result(property = "episodes", column = "chapter_id", jdbcType = JdbcType.INTEGER,javaType = List.class,
                many = @Many(select = "com.yangrui.app.mapper.EpisodeMapper.selectByChapterId"))
    })
    List<Chapter> selectByVideoId(Integer videoId);
}
